// 子组件往父组件传值，设置一个props的方法给子组件，子组件调用这个方法传递参数
import { useState } from "react"
function Detail({onActive}){
    const [status,setStatus] = useState(true)
    function handleClick(e){  
        setStatus(!status)
        onActive(status)
    }
    return (
        <>
        <br></br>
        <br></br>
        <button onClick={handleClick}>点击</button>
        <div style={{
            display: status?'block':'none'
        }}>内容</div>
        </>
    )
}
export default function ChildrenToParent(){
    function handleActive(status){  
        console.log(status)
    }
    return (
        <>
        <Detail onActive={handleActive}>
        </Detail>
        </>
    )
}